package com.jwaoo.chat.session.actions;

import com.jwaoo.chat.ChatConstants;
import com.jwaoo.chat.Message;
import com.jwaoo.chat.R;
import com.jwaoo.chat.attachment.FileAttachment;
import com.jwaoo.chat.bitmap.BitmapDecoder;
import com.jwaoo.chat.data.db.MessageHandler;
import java.io.File;
/**
 * Created by zhoujianghua on 2015/7/31.
 */
public class SnapChatAction extends PickImageAction {

    public SnapChatAction() {
        super(R.drawable.dialogue_more_fire_btn, R.string.input_panel_snapchat, false);
    }

    @Override
    protected void onPicked(File file,int snap) {

        FileAttachment fileAttachment = new FileAttachment();
        fileAttachment.setPath(file.getPath());
        fileAttachment.setSize(file.length());
        int bound[] = BitmapDecoder.decodeBound(file);
        fileAttachment.setWidth(bound[0]);
        fileAttachment.setHeight(bound[1]);
        fileAttachment.setAttachstate(ChatConstants.transferring);
//        fileAttachment.setSnap(snap);
        Message message = MessageHandler.getInstace(getActivity().getApplicationContext()).createMessage(ChatConstants.snap,getContainer().account,fileAttachment);
        sendMessage(message);
    }
}
